// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:"cloud2-4gncvam39e2323e9",
})
const db=cloud.database();

/* 根据当前用户openid从表userALL查询用户信息 */
exports.main = async (event, context) => {
  const openid = cloud.getWXContext().OPENID
  var res=await db.collection("userAll").where({
    openid
  }).get();

  if(res.data.length){
    return {data:res.data[0],code:200}
  }else{
    return {code:400}
  }
  
}